#include "dbpath.h"
#include "myutils.h"

#include <QDate>

DBPath::DBPath()
{
    initDBPath();
}

void DBPath::SetDRPath(const std::string &date)
{
    QString dateString = QString::fromStdString(date);

    QString dbDir = QString("/home/nvidia/data/Hardware/%1/T00032/database/")
            .arg(dateString);

    QString dbName = QString("T00032_%1_dr.db")
            .arg(dateString);

    QString dbPath = dbDir + dbName;
    string path = dbPath.toStdString();

    MyUtils::mkMultiDir(dbDir);

    dr_db_path = path;
}

string DBPath::GetDRPath()
{
    return dr_db_path;
}

void DBPath::initDBPath()
{
    QDate m_date = QDate::currentDate();
    QString dateString = m_date.toString("yyyy_MM_dd");

    QString dbDir = QString("/home/nvidia/data/Hardware/%1/T00032/database/")
            .arg(dateString);

    QString dbName = QString("T00032_%1_dr.db")
            .arg(dateString);

    QString dbPath = dbDir + dbName;

    MyUtils::mkMultiDir(dbDir);

    dr_db_path = dbPath.toStdString();
}
